package com.ruicar.afs.cloud.apply.pre.loan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruicar.afs.cloud.apply.common.entity.ApplyModifyHistory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 耿继辉
 */
public interface ApplyModifyHistoryMapper extends BaseMapper<ApplyModifyHistory> {

    /**
     * 获取最大版本号
     * @param applyNo
     * @return
     */
    @Select("select max(t.version) version from apply_modify_history t where t.apply_no = #{applyNo}")
    Integer getMaxVersion(@Param("applyNo") String applyNo);

    /**
     * 版本号为空-查询历史版本号
     * @param applyNo
     * @return
     */
    @Select("select * from apply_modify_history where apply_no = #{applyNo} and (version is null or version = '')")
    ApplyModifyHistory getModifyHistory(@Param("applyNo") String applyNo);

}
